<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::Timestamp::Request - openssl: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-algorithm">#algorithm</a>
    <li ><a href="#method-i-algorithm-3D">#algorithm=</a>
    <li ><a href="#method-i-cert_requested-3D">#cert_requested=</a>
    <li ><a href="#method-i-cert_requested-3F">#cert_requested?</a>
    <li ><a href="#method-i-message_imprint">#message_imprint</a>
    <li ><a href="#method-i-message_imprint-3D">#message_imprint=</a>
    <li ><a href="#method-i-nonce">#nonce</a>
    <li ><a href="#method-i-nonce-3D">#nonce=</a>
    <li ><a href="#method-i-policy_id">#policy_id</a>
    <li ><a href="#method-i-policy_id-3D">#policy_id=</a>
    <li ><a href="#method-i-to_der">#to_der</a>
    <li ><a href="#method-i-version">#version</a>
    <li ><a href="#method-i-version-3D">#version=</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OpenSSL::Timestamp::Request">
    <h1 id="class-OpenSSL::Timestamp::Request" class="class">
      class OpenSSL::Timestamp::Request
    </h1>

    <section class="description">
    
<p>Allows to create timestamp requests or parse existing ones. A <a href="Request.html"><code>Request</code></a> is also needed for creating timestamps from scratch with <a href="Factory.html"><code>Factory</code></a>. When created from scratch, some default values are set:</p>
<ul><li>
<p>version is set to <code>1</code></p>
</li><li>
<p>cert_requested is set to <code>true</code></p>
</li><li>
<p>algorithm, <a href="Request.html#method-i-message_imprint"><code>message_imprint</code></a>, <a href="Request.html#method-i-policy_id"><code>policy_id</code></a>, and nonce are set to <code>false</code></p>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::Timestamp::Request.new(file)    &rarr; request
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::Timestamp::Request.new(string)  &rarr; request
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::Timestamp::Request.new          &rarr; empty request
                              </span>
                            </div>

                            <div class="method-description">
                              <p>When creating a <a href="Request.html"><code>Request</code></a> with the <code>File</code> or <code>string</code> parameter, the corresponding <code>File</code> or <code>string</code> must be DER-encoded.</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
ossl_ts_req_initialize(int argc, VALUE *argv, VALUE self)
{
    TS_REQ *ts_req = DATA_PTR(self);
    BIO *in;
    VALUE arg;

    if(rb_scan_args(argc, argv, &quot;01&quot;, &amp;arg) == 0) {
        return self;
    }

    arg = ossl_to_der_if_possible(arg);
    in = ossl_obj2bio(&amp;arg);
    ts_req = d2i_TS_REQ_bio(in, &amp;ts_req);
    BIO_free(in);
    if (!ts_req) {
        DATA_PTR(self) = NULL;
        ossl_raise(eTimestampError, &quot;Error when decoding the timestamp request&quot;);
    }
    DATA_PTR(self) = ts_req;

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-algorithm" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          algorithm    &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the ‘short name’ of the object identifier that represents the algorithm that was used to create the message imprint digest.</p>

                              <div class="method-source-code" id="algorithm-source">
            <pre>static VALUE
ossl_ts_req_get_algorithm(VALUE self)
{
    TS_REQ *req;
    TS_MSG_IMPRINT *mi;
    X509_ALGOR *algor;

    GetTSRequest(self, req);
    mi = TS_REQ_get_msg_imprint(req);
    algor = TS_MSG_IMPRINT_get_algo(mi);
    return get_asn1obj(algor-&gt;algorithm);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-algorithm-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          algorithm = &quot;string&quot;    &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Allows to set the object identifier  or the ‘short name’ of the algorithm that was used to create the message imprint digest.</p>

<h3 id="method-i-algorithm-3D-label-Example-3A">Example:<span><a href="#method-i-algorithm-3D-label-Example-3A">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-identifier">request</span>.<span class="ruby-identifier">algorithm</span> = <span class="ruby-string">&quot;SHA1&quot;</span>
</pre>

                              <div class="method-source-code" id="algorithm-3D-source">
            <pre>static VALUE
ossl_ts_req_set_algorithm(VALUE self, VALUE algo)
{
    TS_REQ *req;
    TS_MSG_IMPRINT *mi;
    ASN1_OBJECT *obj;
    X509_ALGOR *algor;

    GetTSRequest(self, req);
    obj = obj_to_asn1obj(algo);
    mi = TS_REQ_get_msg_imprint(req);
    algor = TS_MSG_IMPRINT_get_algo(mi);
    if (!X509_ALGOR_set0(algor, obj, V_ASN1_NULL, NULL)) {
        ASN1_OBJECT_free(obj);
        ossl_raise(eTimestampError, &quot;X509_ALGOR_set0&quot;);
    }

    return algo;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cert_requested-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          cert_requested = boolean &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Specify whether the response shall contain the timestamp authority’s certificate or not. The default value is <code>true</code>.</p>

                              <div class="method-source-code" id="cert_requested-3D-source">
            <pre>static VALUE
ossl_ts_req_set_cert_requested(VALUE self, VALUE requested)
{
    TS_REQ *req;

    GetTSRequest(self, req);
    TS_REQ_set_cert_req(req, RTEST(requested));

    return requested;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cert_requested-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          cert_requested?  &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Indicates whether the response shall contain the timestamp authority’s certificate or not.</p>

                              <div class="method-source-code" id="cert_requested-3F-source">
            <pre>static VALUE
ossl_ts_req_get_cert_requested(VALUE self)
{
    TS_REQ *req;

    GetTSRequest(self, req);
    return TS_REQ_get_cert_req(req) ? Qtrue: Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-message_imprint" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          message_imprint    &rarr; string or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the message imprint (digest) of the data to be timestamped.</p>

                              <div class="method-source-code" id="message_imprint-source">
            <pre>static VALUE
ossl_ts_req_get_msg_imprint(VALUE self)
{
    TS_REQ *req;
    TS_MSG_IMPRINT *mi;
    ASN1_OCTET_STRING *hashed_msg;
    VALUE ret;

    GetTSRequest(self, req);
    mi = TS_REQ_get_msg_imprint(req);
    hashed_msg = TS_MSG_IMPRINT_get_msg(mi);

    ret = rb_str_new((const char *)hashed_msg-&gt;data, hashed_msg-&gt;length);

    return ret;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-message_imprint-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          message_imprint = &quot;string&quot;    &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Set the message imprint digest.</p>

                              <div class="method-source-code" id="message_imprint-3D-source">
            <pre>static VALUE
ossl_ts_req_set_msg_imprint(VALUE self, VALUE hash)
{
    TS_REQ *req;
    TS_MSG_IMPRINT *mi;
    StringValue(hash);

    GetTSRequest(self, req);
    mi = TS_REQ_get_msg_imprint(req);
    if (!TS_MSG_IMPRINT_set_msg(mi, (unsigned char *)RSTRING_PTR(hash), RSTRING_LENINT(hash)))
        ossl_raise(eTimestampError, &quot;TS_MSG_IMPRINT_set_msg&quot;);

    return hash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-nonce" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          nonce    &rarr; BN or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the nonce (number used once) that the server shall include in its response.</p>

                              <div class="method-source-code" id="nonce-source">
            <pre>static VALUE
ossl_ts_req_get_nonce(VALUE self)
{
    TS_REQ *req;
    const ASN1_INTEGER * nonce;

    GetTSRequest(self, req);
    if (!(nonce = TS_REQ_get_nonce(req)))
        return Qnil;
    return asn1integer_to_num(nonce);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-nonce-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          nonce = number    &rarr; BN
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the nonce (number used once) that the server shall include in its response. If the nonce is set, the server must return the same nonce value in a valid <a href="Response.html"><code>Response</code></a>.</p>

                              <div class="method-source-code" id="nonce-3D-source">
            <pre>static VALUE
ossl_ts_req_set_nonce(VALUE self, VALUE num)
{
    TS_REQ *req;
    ASN1_INTEGER *nonce;
    int ok;

    GetTSRequest(self, req);
    nonce = num_to_asn1integer(num, NULL);
    ok = TS_REQ_set_nonce(req, nonce);
    ASN1_INTEGER_free(nonce);
    if (!ok)
        ossl_raise(eTimestampError, NULL);
    return num;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-policy_id" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          policy_id    &rarr; string or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the ‘short name’ of the object identifier that represents the timestamp policy under which the server shall create the timestamp.</p>

                              <div class="method-source-code" id="policy_id-source">
            <pre>static VALUE
ossl_ts_req_get_policy_id(VALUE self)
{
    TS_REQ *req;

    GetTSRequest(self, req);
    if (!TS_REQ_get_policy_id(req))
        return Qnil;
    return get_asn1obj(TS_REQ_get_policy_id(req));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-policy_id-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          policy_id = &quot;string&quot;   &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Allows to set the object identifier that represents the timestamp policy under which the server shall create the timestamp. This may be left <code>nil</code>, implying that the timestamp server will issue the timestamp using some default policy.</p>

<h3 id="method-i-policy_id-3D-label-Example-3A">Example:<span><a href="#method-i-policy_id-3D-label-Example-3A">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-identifier">request</span>.<span class="ruby-identifier">policy_id</span> = <span class="ruby-string">&quot;1.2.3.4.5&quot;</span>
</pre>

                              <div class="method-source-code" id="policy_id-3D-source">
            <pre>static VALUE
ossl_ts_req_set_policy_id(VALUE self, VALUE oid)
{
    TS_REQ *req;
    ASN1_OBJECT *obj;
    int ok;

    GetTSRequest(self, req);
    obj = obj_to_asn1obj(oid);
    ok = TS_REQ_set_policy_id(req, obj);
    ASN1_OBJECT_free(obj);
    if (!ok)
        ossl_raise(eTimestampError, &quot;TS_REQ_set_policy_id&quot;);

    return oid;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_der" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_der    &rarr; DER-encoded string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>DER-encodes this <a href="Request.html"><code>Request</code></a>.</p>

                              <div class="method-source-code" id="to_der-source">
            <pre>static VALUE
ossl_ts_req_to_der(VALUE self)
{
    TS_REQ *req;
    TS_MSG_IMPRINT *mi;
    X509_ALGOR *algo;
    ASN1_OCTET_STRING *hashed_msg;

    GetTSRequest(self, req);
    mi = TS_REQ_get_msg_imprint(req);

    algo = TS_MSG_IMPRINT_get_algo(mi);
    if (OBJ_obj2nid(algo-&gt;algorithm) == NID_undef)
        ossl_raise(eTimestampError, &quot;Message imprint missing algorithm&quot;);

    hashed_msg = TS_MSG_IMPRINT_get_msg(mi);
    if (!hashed_msg-&gt;length)
        ossl_raise(eTimestampError, &quot;Message imprint missing hashed message&quot;);

    return asn1_to_der((void *)req, (int (*)(void *, unsigned char **))i2d_TS_REQ);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-version" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          version &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the version of this request. <code>1</code> is the default value.</p>

                              <div class="method-source-code" id="version-source">
            <pre>static VALUE
ossl_ts_req_get_version(VALUE self)
{
    TS_REQ *req;

    GetTSRequest(self, req);
    return LONG2NUM(TS_REQ_get_version(req));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-version-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          version = number    &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the version number for this <a href="Request.html"><code>Request</code></a>. This should be <code>1</code> for compliant servers.</p>

                              <div class="method-source-code" id="version-3D-source">
            <pre>static VALUE
ossl_ts_req_set_version(VALUE self, VALUE version)
{
    TS_REQ *req;
    long ver;

    if ((ver = NUM2LONG(version)) &lt; 0)
        ossl_raise(eTimestampError, &quot;version must be &gt;= 0!&quot;);
    GetTSRequest(self, req);
    if (!TS_REQ_set_version(req, ver))
        ossl_raise(eTimestampError, &quot;TS_REQ_set_version&quot;);

    return version;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

